﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace ApplicationGenerator.CommonModule
{
    public class MappingsConverterHelper
    {
        public static byte[] ConvertToString(Mappings mappings)
        {
            MemoryStream writer = new MemoryStream();
            BinaryFormatter serializer = new BinaryFormatter();
            serializer.Serialize(writer, mappings);
            return writer.ToArray();
        }

        public static Mappings ConvertToMappings(byte[] mappings)
        {
            MemoryStream reader = new MemoryStream(mappings);
            BinaryFormatter deserializer = new BinaryFormatter();
            return (Mappings)deserializer.Deserialize(reader);
        }
    }
}
